package secondkill.controller;

import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import secondkill.pojo.TUser;
import secondkill.service.ITOrderService;
import secondkill.vo.OrderDetailVo;
import secondkill.vo.RespBean;
import secondkill.vo.RespBeanEnum;

/**
 * <p>
 *  前端控制器
 * </p>
 * @author Dzy
 * @since 2022-01-19
 */
//订单页面静态化处理 通过ajax来返回页面数据
@Slf4j
@RestController
@RequestMapping("/order")
public class TOrderController {
    @Autowired
    private ITOrderService orderService;
    /**
     * @param user
     * @param orderId
     * @return
     */
    @RequestMapping("/orderDetail")
    @ResponseBody
    public RespBean detail(TUser user, Long orderId) {
        if(ObjectUtil.isEmpty(user)){
            return RespBean.error(RespBeanEnum.SESSION_ERROR);
        }
        OrderDetailVo detail = orderService.detail(orderId);
        log.info("<<<<<<<<<<<<detail:{}",detail);
        return RespBean.success(detail);
    }
}
